package com.ict.controller;


import com.ict.api.dto.IctSkuStockDTO;
import com.ict.api.result.ApiResponse;
import com.ict.api.vo.IctSkuStockVO;
import com.ict.service.IctSkuStockService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * sku的库存 前端控制器
 * </p>
 *
 * @author wjp
 * @since 2025-03-23
 */
@RestController
@RequestMapping("/ict-sku-stock")
public class IctSkuStockController {

    @Resource
    private IctSkuStockService stockService;

    @GetMapping("/getStockInfo")
    public ApiResponse<List<IctSkuStockVO>> getStockInfo(IctSkuStockDTO skuStockDTO) {
        List<IctSkuStockVO> stock = stockService.getStockInfo(skuStockDTO);

        return ApiResponse.success(stock);
    }

    @PostMapping("/addStockInfo")
    public ApiResponse<String> addStockInfo(@RequestBody IctSkuStockDTO stockAddDTO) {
        return stockService.addStockInfo(stockAddDTO);
    }

    @PutMapping("/deduct")
    public ApiResponse<String> deductStock(@RequestBody IctSkuStockDTO stockDeductDTO) {
        return stockService.deductStock(stockDeductDTO);
    }

    @PutMapping("/add")
    public ApiResponse<String> addStock(@RequestBody IctSkuStockDTO stockAddDTO) {
        return stockService.addStock(stockAddDTO);
    }

    @PutMapping("/lock")
    public ApiResponse<String> lockStock(@RequestBody @Validated IctSkuStockDTO stockLockDTO) {
        return stockService.lockStock(stockLockDTO);
    }

    @PutMapping("/unlock")
    public ApiResponse<String> unlockStock(@RequestBody @Validated IctSkuStockDTO stockUnlockDTO) {
        return stockService.unlockStock(stockUnlockDTO);
    }
}

